package com.example.pxxy_news.adapter;

import java.util.List;

import com.example.pxxy_news.R;
import com.example.pxxy_news.application.MyApplication;

import entity.Comment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class CommentAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private Context context;
	private List<Comment> list;

	public CommentAdapter(List<Comment> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			inflater = LayoutInflater.from(MyApplication.getContext());
			convertView = inflater.inflate(R.layout.listview_comment, null);
		}
		// �õ�Ҫ�������ݵĿؼ�
		TextView tv_username = (TextView) convertView
				.findViewById(R.id.list_comment_username);
		TextView tv_content = (TextView) convertView
				.findViewById(R.id.list_comment_content);
		TextView tv_time = (TextView) convertView
				.findViewById(R.id.list_comment_date);
		
		// ��������
		tv_username.setText(list.get(position).getUsername());
		tv_content.setText(list.get(position).getComment_content());
		tv_time.setText(list.get(position).getComment_date());
		return convertView;

	}

}
